﻿using System;
using System.Data;
using Guru.Data;

public partial class FE_FrontDesk : HSMPage
{    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.uxDiagrams.RoomList = this.GetRooms();
            this.uxDiagrams.DataBind();           
        }
    }
    protected void uxReload_Click(object sender, EventArgs e)
    {
        this.uxDiagrams.RoomList = this.GetRooms();
        this.uxDiagrams.DataBind();
    }
    protected void uxFiltering_HotelFiltered(object sender, EventArgs e)
    {
        this.uxDiagrams.RoomList = this.GetRooms();
        this.uxDiagrams.DataBind();
    }
    protected DataTable GetRooms()
    {
        GuruParameterCollection parameters = new GuruParameterCollection();
        parameters.AddUserLoggedParams();
        parameters.Add("@ViewDate", HSMSessionManager.HotelFilterOptions.ViewDate, DbType.Date);
        if (!string.IsNullOrEmpty(HSMSessionManager.HotelFilterOptions.RoomType))
        {
            parameters.Add("@RoomType", HSMSessionManager.HotelFilterOptions.RoomType, DbType.Int32);
        }
        if (!string.IsNullOrEmpty(HSMSessionManager.HotelFilterOptions.RoomStatus))
        {
            parameters.Add("@RoomStatus", HSMSessionManager.HotelFilterOptions.RoomStatus, DbType.Int32);
        }
        DataTable rooms = HSMCommon.HSMBusiness.GetDataTable("spa_HSM_Room_GetFromDeskDiagram", parameters);
        return rooms;
    }
    protected void DoContextMenuClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
    {
        if (uxDiagrams.SelectedRooms != null && uxDiagrams.SelectedRooms.Count > 0)
        {
            int roomID = int.Parse(uxDiagrams.SelectedRooms[0]);
            GuruParameterCollection parameters = new GuruParameterCollection();
            parameters.AddUserLoggedParams();
            parameters.Add("@RoomID", roomID, DbType.Int32);

            switch (e.Item.Value.Trim())
            {
                case "Maintenance":
                    parameters.Add("@Status", HSMEnums.RoomStatus.Maintenance, DbType.Int32);
                    break;
                case "ChangeToEmpty":
                    parameters.Add("@Status", HSMEnums.RoomStatus.Empty, DbType.Int32);
                    break;
            }
            HSMCommon.HSMBusiness.UpdateData("spa_HSM_Room_UpdateStatus", parameters);
            uxReload_Click(sender, null);
        }
    }
}
